<?php
// +----------------------------------------------------------------------
// |产品管理控制器
// +----------------------------------------------------------------------


namespace app\Api\controller;

use app\BaseController;
use app\common\Model\ConfigModel;
use think\facade\Db;
use think\facade\Cache;
use app\Api\system\GetProducrServicr;
use think\facade\Request;
 
class GetProducr extends BaseController
{


  
    //dh.category.list$2.0 (获取类目列表接口)
    public function category_get()
    {
      $shop_id= Request::get("shop_id");
      if(empty($shop_id)){
        return json(['code' => 0,'msg' => '缺少shop_id参数']);
      }
      $accessToken=$this->getTokenByCode($shop_id);     
      $res=GetProducrServicr::category_get($accessToken);
      print_r($res);    
  }


    //dh.category.list$2.0 (获取类目列表接口)
    public function category_list()
    {
      $shop_id= Request::get("shop_id");
      if(empty($shop_id)){
        return json(['code' => 0,'msg' => '缺少shop_id参数']);
      }
      $accessToken=$this->getTokenByCode($shop_id);     
      $res=GetProducrServicr::category_list($accessToken);
      print_r($res);    
  }


  
    //dh.category.list$2.0 (获取类目列表接口)
    public function category_get_datail()
    {
      $shop_id= Request::get("shop_id");
      if(empty($shop_id)){
        return json(['code' => 0,'msg' => '缺少shop_id参数']);
      }
      $accessToken=$this->getTokenByCode($shop_id);     
      $res=GetProducrServicr::category_get_datail($accessToken);
      print_r($res);    
  }




    
    //dh.album.img.upload$2.0 (卖家上传产品图片接口)
     //商品图片轮播图上传接口
     public function album_image_update(){
       $shop_id= Request::get("shop_id");     
      if(empty($shop_id)){
         $shop_id=1;
      }
      $accessToken=$this->getTokenByCode($shop_id);     
      $res=GetProducrServicr::album_image_update($accessToken,$shop_id);
      print_r( $res);die;     
    }


     //dh.album.img.upload$2.1 (卖家上传产品图片接口)
     //图片上传详情接口
    public function album_image_dateil(){
       $shop_id= Request::get("shop_id");     
      if(empty($shop_id)){
         $shop_id=1;
      }
      $accessToken=$this->getTokenByCode($shop_id);     
      $res=GetProducrServicr::album_image_dateil($accessToken,$shop_id);    
      print_r( $res);die;
    }

    //dh.item.add$2.0 (卖家发布产品信息接口)
    public function item_add(){
       $receivedData =file_get_contents('php://input');
        $param =  json_decode($receivedData,true);
        if(empty($param)){
          return json(['code' => 0,'msg' => '缺少参数']);
        }
        $shop_id= $param['shop_id'];
        if(empty($shop_id)){
          $shop_id=1;
        }   
        $accessToken=$this->getTokenByCode($shop_id);     
        $res=GetProducrServicr::item_add($accessToken,$param);
       success($res);die; 
    }

   //dh.categorys.commissions$1.0 (获取佣金率列表)
    public function commissions(){
        $shop_id= Request::get("shop_id");     
      if(empty($shop_id)){
         $shop_id=1;
      }
      $accessToken=$this->getTokenByCode($shop_id);     
      $res=GetProducrServicr::commissions($accessToken,$shop_id);
      success($res);die; 
    }

    //抓取1688的详情产品
    public function item_detail_1688(){
      $res=GetProducrServicr::item_detail_1688();
      success($res);die; 
    }


}
